< previous page page_99 next page >

Page 99
One of these events is the GotFocus event for the text box. This event occurs every time the user moves to the text box, either by clicking the mouse or using the Tab key. Also, when the text box gets the program's focus, another control must lose the focus. This action causes a LostFocus event to fire for the other control. The GotFocus and LostFocus events are caused by the user's action, just as the Click event is. As you will see in the upcoming section "Understanding Event Sequences," multiple events can occur for each action a user takes. The order in which the events occur can be important.
The following are some of the main user actions that trigger events in a program:
Starting the program
Pressing a key
Clicking the mouse
Moving the mouse
Closing the program
System Events
Although forms and controls can respond to many different events, many controls have several events in common, as you can see in Table 5.1.
Table 5.1 Events Common to Many Controls
EventOccurs When
ChangeThe user modifies the text in a text box or combo box.
ClickThe user clicks an object with the primary mouse button (usually the left button).
DblClickThe user double-clicks an object with the primary mouse button.
DragDropThe user drags a control to another location.
DragOverAn object is dragged over a control.
GotFocusAn object receives the focus.
KeyDownA key is pressed while an object has the focus.
KeyPressA key is pressed and released while an object has the focus.
KeyUpA key is released while an object has the focus.
LostFocusThe focus has left an object.
MouseDownA mouse button is pressed while the mouse pointer is over an object.
MouseMoveThe mouse cursor is moved over an object.
MouseUpA mouse button is released whilethe mouse pointer is over an object.

You might have noticed that several of the events seem to correspond to the same user action. For example, the Click, MouseDown, and MouseUp events all occur when the user clicks the

 
< previous page page_99 next page >